package com.lanchetech.dao;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.request.WithdrawReq;import com.lanchetech.bean.response.WithdrawResp;import com.lanchetech.bean.vo.CountByTimeVO;
import com.lanchetech.bean.vo.WithdrawRespVO;
import com.lanchetech.bean.vo.WithdrawVO;
import com.lanchetech.entity.Withdraw;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import org.apache.ibatis.annotations.Select;import java.math.BigDecimal;import java.util.List;

@Mapper
public interface WithdrawMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Withdraw record);

    int insertSelective(Withdraw record);

    Withdraw selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Withdraw record);

    int updateByPrimaryKey(Withdraw record);

    List<WithdrawResp> findAllPage(WithdrawReq req);

    @Select("select sum(amount) from withdraw where user_id = #{userId} and DATE_FORMAT(now(),'%Y-%M-%D') = DATE_FORMAT(created_at,'%Y-%M-%D') and status = 1")
    BigDecimal sumAmountOfDay(Long userId);

    Long countByStatus(@Param("status") Integer status);

    BigDecimal sumByUserIdAndStatus(@Param("userId") Long userId, @Param("status") Integer status, @Param("businessType") Byte businessType);

    BigDecimal sumByUserIdAndStatusAndBusinessTypeAndShopId(@Param("userId") Long userId, @Param("status") Integer status, @Param("businessType") Byte businessType, @Param("shopId") Long shopId);

    BigDecimal sumByUserIdAndStatusAndBusinessType(@Param("userId") Long userId, @Param("status") Integer status, @Param("businessType") Byte businessType);

    BigDecimal sumAmountByTime(WithdrawReq req);

    List<CountByTimeVO> getWithdrawByMonth(@Param("userId") Long userId, @Param("status") Integer status);

    BigDecimal sumByUserIdAndStatus2(@Param("userId") Long userId, @Param("status") Integer status);

    List<WithdrawRespVO> findAllRespPage(PageReq req);

    List<WithdrawRespVO> findWithdrawRank(PageReq req);
}